feat(core): return cesium credit conditionally in getCredits - #144
Merged
Conversation
…re in use Add `hasCesiumIonAsset?: boolean` to `EngineProps` and thread it through the engine stack so `getCredits()` omits `engine.cesium` when the flag is explicitly `false`. Callers that do not pass the flag receive the existing behavior (`undefined` → credit included) for full backward compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 tasks
Detection logic was previously passed in from the visualizer as a prop (`hasCesiumIonAsset`). Core already owns both `property` (ViewerProperty) and `layers` (Layer[]) in `Map/index.tsx`, so computing the boolean there keeps Ion-awareness entirely within core — consistent with how credits are already surfaced via `getCredits`. `CoreVisualizerProps` no longer exposes `hasCesiumIonAsset`; callers are unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ZTongci
force-pushed
the
feat/conditional-cesium-ion-credit
branch
from
July 9, 2026 06:27
ca14a30 to
d5a27b4
Compare
airslice
reviewed
Jul 13, 2026
airslice
reviewed
Jul 13, 2026
- google-photorealistic: only check provider === "cesium-ion" (drop serviceTokens check) - remove 3dtiles type restriction from URL check (isIonUrl applies to any layer type) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the Cesium credit emission conditional on whether Cesium-ion assets are actually in use, by computing an internal hasCesiumIonAsset flag in the core Map component and plumbing it down into Cesium’s getCredits().
Changes:
- Add Cesium-ion usage detection (
computeHasCesiumIonAsset) based on viewer property (tiles/terrain) and layer tree analysis. - Compute
hasCesiumIonAssetinsidesrc/Map/index.tsx(kept internal viaOmit) and pass it to the engine. - Update Cesium engine hooks and
getCredits(viewer, hasCesiumIonAsset?)to suppress the Cesium credit whenhasCesiumIonAsset === false.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Map/types/index.ts | Adds hasCesiumIonAsset?: boolean to EngineProps for engine-level plumbing. |
| src/Map/index.tsx | Computes hasCesiumIonAsset via useMemo and passes it to the engine while preventing external override. |
| src/Map/cesiumIonDetection.ts | New Cesium-ion usage detection helper (tiles, terrain, layers, recursive groups). |
| src/engines/Cesium/index.tsx | Forwards hasCesiumIonAsset into Cesium hooks. |
| src/engines/Cesium/hooks.ts | Stores hasCesiumIonAsset in a ref and threads it to credit polling and useEngineRef. |
| src/engines/Cesium/hooks/useEngineRef.ts | Passes hasCesiumIonAssetRef.current through the imperative getCredits() API. |
| src/engines/Cesium/common.ts | Updates getCredits signature and conditionally suppresses Cesium credit when explicitly no Ion assets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Covers tiles, terrain, layers (osm-buildings, google-photorealistic, ion URL), LayerGroup recursion, and edge cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The Cesium-ion logo was always shown in the credit display, even when the scene contained no Cesium-ion assets.
creditDisplay._currentCesiumCreditis populated by Cesium as soon as the viewer initialises, regardless of whether any Ion asset is actually loaded.This change computes whether Ion assets are in use inside the core's
Mapcomponent — the only place that already has access to bothproperty(ViewerProperty) andlayers(Layer[]) — and threads the result down togetCredits()so the credit is only emitted when Ion assets are genuinely present.What I've done
src/Map/cesiumIonDetection.ts(new) —computeHasCesiumIonAsset(property, layers)detects Ion usage across:typestarts withcesium_ion, or is a legacy alias (default,default_road,default_label,black_marble).cesiumorcesiumionwithenabled: true, orassets.cesium.terrain.ionUrlcontainsion.cesium.com.osm-buildings,google-photorealisticnot routed through Google Maps API, or3dtileswith anion.cesium.comURL. Recurses intoLayerGroup.children.src/Map/index.tsx— ComputeshasCesiumIonAssetinternally viauseMemoand passes it to the engine.hasCesiumIonAssetis excluded fromMap.PropsviaOmitso external callers cannot set it.src/Visualizer/index.tsx— RemovedhasCesiumIonAssetfromCoreVisualizerProps; callers no longer need to know about Ion detection.src/engines/Cesium/common.ts—getCredits(viewer, hasCesiumIonAsset?)setsengine.cesiumtoundefinedwhenhasCesiumIonAsset === false.undefined(not provided) preserves existing behavior.src/engines/Cesium/hooks.ts— AcceptshasCesiumIonAsset, stores it in a ref, passes ref touseEngineRefand value togetCredits.src/engines/Cesium/index.tsx— Destructures and forwardshasCesiumIonAssettouseHooks.src/engines/Cesium/hooks/useEngineRef.ts— PasseshasCesiumIonAssetRef.currenttogetCredits.How I tested
Manually verified: default scene (OSM tile + reearth terrain) → logo hidden; switching to a Cesium Ion tile → logo appears; switching back → logo disappears after the next 3-second credit poll.
Backward compatibility
hasCesiumIonAsset === falseis the only case that suppresses the credit. When the flag computes toundefinedortrue, the existing behavior is preserved.